home *** CD-ROM | disk | FTP | other *** search
/ Network CD 2 / Network CD - Volume 2.iso / programs / internet / dnet / dshterm1_0.lha / include / st / textmessage.h < prev   
Encoding:
C/C++ Source or Header  |  1992-02-04  |  1.8 KB  |  58 lines

  1. /* text.h */
  2.  
  3. /* some message port things */
  4. #define REPLYPORT(a) ((a)->mn_ReplyPort)
  5. #define TMREPLYPORT(a) (REPLYPORT(&((a)->Msg)))
  6.  
  7. /* string length... if -1 check for where the null termination is */
  8. #define STRLEN(a) ((((a)->StrLen==-1)?strlen((a)->String):(a)->StrLen))
  9. #define STR(a) (a->String)
  10.  
  11.  
  12. /* Messages sent/received are in this format */
  13. /* Usually for text but may send other things if U like */
  14.  
  15. struct String0 {
  16.         char *String;        /* pointer to memory of string */
  17.         long StrLen;        /* actual string length (or -1 for NULL termination) */
  18.         long FreeLen;        /* If string is to be freed, how much mem was alloc'd */
  19. };
  20. /*
  21.   the receiver should do the following:
  22.     if(FreeLen > 0) FreeMem(String, FreeLen);
  23.   when finished with the string
  24. */
  25.  
  26. struct TextMessage {
  27.         struct    Message Msg;
  28.         long    Command;        /* What should we do?? */
  29.         struct    String0 String;
  30.         struct    String0 RepString;
  31.         long    Args[8];        /* 8 arguments */
  32.         void    *Extra;            /* expandable! */
  33.  
  34. };
  35.  
  36. /* Currently defined commands (default) */
  37. #define TM_TEXT            't'                /* ordinary text.. send it or whateever */
  38. #define TM_EXIT            'q'                /* tell receiver to die */
  39. #define TM_SETWIDTH        'w'                /* set window width */
  40. #define TM_SETHEIGHT    'l'                /* Set window height */
  41. #define TM_HELP            'h'                /* ask receiver known command */
  42. #define TM_COMMAND        'c'                /* Send a command to receiver */
  43.  
  44. /*
  45. When replying totextmessages the receiver should either use the supplied
  46. SafeReplyTextMessage(message), where message is a pointer to the sent
  47. message
  48. or other wise perform the following steps:
  49. SafeFreeString0(&(msg->String)); which sets that pointer to NULL also
  50.         if(TMREPLYPORT(msg))
  51.             ReplyMsg((struct Message *)msg);
  52.         else FreeMem(msg, sizeof(struct TextMessage));
  53.  
  54. this means that if the sender does not want thestring or the message freed
  55. then it should have areply port for it to be returned.
  56. */
  57.  
  58.